home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1994 December / PSL Monthly Shareware CD-ROM (Public Software Library)(December 1994).bin / prgmming / win / vb_sys / dirscan.bas (.txt) < prev    next >
Visual Basic Form  |  1992-03-09  |  7KB  |  150 lines

  1. DirScanForm
  2. Directory Structure Scan
  3. Form1
  4. Frame1
  5. 3          Click on Begin Scan  to Start            
  6. Label1
  7. Searching: 
  8. DirDisp
  9. BeginBut
  10. Begin Scan
  11.     CancelBut
  12. Abort Scan
  13. Frame2
  14. Please Select a Directory:
  15. FoundBox
  16. CanBut
  17. Cancel
  18. OKBut
  19. DriveBox
  20. DirBox
  21. FileBox
  22. SearchList
  23.     FoundList
  24. LastList
  25. EndList
  26. TopNum}
  27. Foundf
  28.     ThisDrive
  29. Valid
  30. MakeTreeList
  31. Screen
  32. MousePointer
  33. FileBox
  34. Pattern\
  35. SEARCHCRITERIA
  36. DriveBox8
  37.     ListCountn
  38. List>
  39. CheckDriveValidU
  40. FALSE
  41. LoopIt
  42. FoundBox%
  43. Begin
  44. DirBox
  45. DirDisp
  46. Caption
  47. FoundDir
  48. AddAny
  49. UserChoose
  50. DirScanForm1
  51. Frame1
  52. Visible
  53. Frame2
  54. Handler
  55.     ListIndexj
  56. ContinueM
  57.     NoneFound
  58. OKBut_Click
  59. FoundBox_DblClick
  60. CancelBut_Click
  61.     Form_Load
  62. LCenter
  63. Width
  64. TCenter
  65. Height
  66. BeginBut_Click
  67. BeginBut
  68.     CancelBut
  69. Label1
  70. CanBut_Click
  71. DirBox_Change
  72.  This program was written by Joel Rose, February, 1992  'e
  73.  I welcome comments, suggestions, and questions at
  74.  185 Shelley Ave., Elizabeth, N.J. 07208
  75.  * Please use it and distribute it freely! *
  76.  DirScanForm Description
  77.  This form, and its code, is intended to scan a system
  78.  to find all directories, on any drive, that contain
  79.  a file, or set of files. 
  80.  I use it in the event that a file or files a program
  81.  needs are not in the expected directory.t
  82.  This might be the case if the user moved theo
  83.  files to another directory.
  84.  It is a general-purpose alternative to a File Not Found
  85.  Error.a
  86.  The routine performs the scan, and then returns a value
  87.  in the FoundDir variable. In the event that more than one
  88.  directory contains the files in SEARCHCRITERIA, the userr
  89.  is presented with a list of directories from which one must
  90.  be chosen. (It would be preferable, of course, to limit
  91.  SEARCHCRITERIA to something that would only be in one
  92.  directory if being used this way, i.e. as part of a user-
  93.  oriented application.))
  94.  One point to notice. In the event that more than onee
  95.  directory is found, a different set of controls appearr
  96.  on the form. I wanted to limit the size of the form, II
  97.  wanted these controls to be invisible until needed, and
  98.  didn't want to create an additional form. So I used the
  99.  technique of overlapping controls, keeping the currentlyy
  100.  UNUSED ones' Visible property set to FALSE. When they neededd
  101.  to be switched, I only need to swap the Visible properties.
  102.  I hope this routine is useful, both in terms of the finishedd
  103.  product, and in terms of the techniques used (e.g. over--
  104.  lapping controls; use of drive, directory, and file boxes;,
  105.  use of DoEvents(), etc.).
  106.  Please address any comments to me at 70254,3254.i
  107.  Usage Notes
  108.  The Statement that calls this form must be-
  109.    DirScanForm.Show 1   {where the 1 means MODAL}-
  110.  The Project that this form is added to must contain
  111.  in its Global Module the following statements:n
  112.  Global FoundDir as String  {this variable will hold the
  113.  found directory upon exit} 
  114.  Global Const SEARCHCRITERIA = "DOS file mask"
  115.  {where the mask describes the file(s) being
  116.  searched for, such as *.XYZ}e
  117.  (Of course, if necessary, this variable can be changede
  118.   during execution instead of using it as global constant.)
  119.  On exit, this form unloads itself. The calling code should
  120.  examine the FoundDir variable for one of the following three
  121.  conditions:
  122.    FoundDir = ""   ... No directory matched the SEARCHCRITERIA
  123.    FoundDir = "Aborted"
  124.  ... User aborted scan 
  125.    FoundDir = anything else
  126.  ... You have your directory!
  127.  Declarations
  128. 5000 is an arbitrarily chosen-
  129. maximum of number of directories
  130. MakeTreeList
  131. Hourglass
  132. Loop once for each drive in system
  133. Begin directory structure search
  134. Allow screen updating ands
  135. detection of mouse operation
  136. Aborted"
  137. If user cancelledc
  138. Ergo FoundDir = ""
  139. Here, one was found - go select it automatically
  140. OKBut_Click
  141. FoundBox_DblClick
  142. CancelBut_Click
  143. Aborted"
  144. Form_Load
  145. Initialize in case of repeat searchy
  146. BeginBut_Click
  147. Scanning, Please Wait ... 
  148. CanBut_Click
  149. Aborted"
  150.